package com.example.badminton.utils;

import com.example.badminton.entity.User;

public class UserContext {
    private static final ThreadLocal<User> USER_HOLDER = new ThreadLocal<>();

    // 设置当前用户
    public static void setUser(User user) {
        USER_HOLDER.set(user);
    }

    // 获取当前用户
    public static User getUser() {
        return USER_HOLDER.get();
    }

    // 清理当前用户（防止内存泄漏）
    public static void clear() {
        USER_HOLDER.remove();
    }
}